<template>
  <div class="ke">

    <div v-loading='loading' style="padding: 20px;">
      <div class="kflexc">
        <div @click="back()" style="margin-right: 20px; cursor: pointer;"><i class="el-icon-back"></i></div>
        支出审核导入记录
      </div>
      <div class="kflexc" style="margin-top: 20px;">
        <div style="width: 220px; margin-right: 20px; ">
          <el-input v-model="all.log_name" placeholder="导入表名称"></el-input>
        </div>
        <el-button type="danger" round  style="margin-right: 20px;" @click="search()">搜索</el-button>
      </div>
      <el-table :data="list" border style="width: 100%; margin: 20px 0;" ref="multipleTable">
        <el-table-column align='center' prop='log_name' label="导入表名称"></el-table-column>
<!--        <el-table-column align='center' prop='sum_type' label="导入结算方式">
          <template slot-scope="scope">
            <div v-if="scope.row.sum_type == 0">标准结算</div>
            <div v-if="scope.row.sum_type == 1">粗略结算</div>
          </template>
        </el-table-column> -->
        <el-table-column align='center' prop='created_at' label="导入时间"></el-table-column>
        <el-table-column align='center' prop='orders_count' label="导入订单数"></el-table-column>
        <el-table-column align='center' prop='ok_count' label="触发待结算订单数"></el-table-column>
        <el-table-column align='center' label="操作">
          <template slot-scope="scope">
            <div class="kflexc">
              <div style="color: #409EFF; margin: 10px; cursor: pointer;" @click="xiazai1(scope.row)">下载导入原表</div>
              <div style="color: #409EFF; margin: 10px; cursor: pointer;" v-if="scope.row.result_file" @click="xiazai2(scope.row)">下载导入结果</div>
              <div style="color: #409EFF; margin: 10px; cursor: pointer;" @click="chexiao(scope.row)" v-if="scope.row.status != 70">撤销导入</div>
              <div style="color: #999; margin: 10px; cursor: pointer;"  v-if="scope.row.status == 70">已撤销导入</div>
            </div>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination style="text-align: right;" background layout="total,prev, pager, next" :current-page="all.page" @current-change="fanye" :page-size="all.page_size" :total="total"></el-pagination>
    </div>
  </div>
</template>

<script>
  import axios from 'axios'
  import top from '@/components/top.vue'
  import left from '@/components/left.vue'
  import foot from '@/components/foot.vue'
  import moment from "moment";
  import XLSX from 'xlsx';
  import {
      read,utils
    } from 'xlsx'

  export default {
    components: {
      "left": left,
      "top": top,
      "foot": foot
    },
    name: "ke",
    data() {
      return {
        all:{
          page:1,
          page_size:20,
          sum_type:10,
          log_name:"",
          sum_type:10
        },
        loading:false,
        list:"",
        total:0
      }
    },
    created() {
      this.getlist()
    },
    mounted() {

    },
    methods: {
      //获取列表
      chexiao: function(item) {
        axios.post('/api/plan-market/order/settled/import/revoke',{log_id:item.id})
          .then(response => {
            if (response.data.msg.code == 0) {
              this.getlist()
            } else {
              this.$message.error(response.data.msg.info);
            }
          })
      },
      back:function(){
        this.$router.back(-1)
      },
      search:function(){
        this.all.page = 1
        this.getlist()
      },
      //获取列表
      getlist: function() {
        axios.get('/api/plan-market/expend/imp/logs',{params:this.all})
          .then(response => {
            if (response.data.msg.code == 0) {
              this.list = response.data.data.data
              this.total = response.data.data.total
              this.loading = false
            } else {
              this.$message.error(response.data.msg.info);
            }
          })
      },
      //翻页
      fanye: function(page) {
        this.loading = true
        this.all.page = page
        this.getlist()
      },
      daoru:function(){

      },
      //下载模板
      xiazai1: function(item) {
        location.href = location.origin + '/' + item.origin_file

      },
      //下载模板
      xiazai2: function(item) {
        location.href = item.result_file
      },

    }
  }
</script>

<style lang="scss" scoped>
  .ke {
    .powertop {
    	display: flex;
    	background:#f9f9f9;
    }
    .powertopli {
    	flex-basis: 180px;
    	line-height: 50px;
    	border-bottom: 3px #F9F9F9 solid;
    	color: #727272;
    	border-right: 1px #F9F9F9 solid;
    	font-size: 16px;
    	text-align: center;
    }
    .router-link-active {
    	background: #FFFFFF;
    	border-bottom: 3px #2974FF solid;
    }
    /deep/ .el-pagination.is-background .btn-prev:disabled{ background: rgba(246, 246, 246, 0.3); border: 1px rgba(167, 167, 167, 0.3) solid;}
    /deep/ .el-pagination.is-background .btn-next:disabled{ background: rgba(246, 246, 246, 0.3); border: 1px rgba(167, 167, 167, 0.3) solid;}
    /deep/ .el-pagination.is-background .btn-next{ background: rgba(246, 246, 246,1); border: 1px rgba(167, 167, 167,1) solid;}
    /deep/ .el-pagination.is-background .btn-prev{ background: rgba(246, 246, 246,1); border: 1px rgba(167, 167, 167,1) solid;}
    /deep/ .el-pagination.is-background .el-pager li:not(.disabled).active{ background-color: #2974FF;}
    /deep/ .el-pagination.is-background .el-pager li:not(.disabled).active:hover {
        color: #fff;
    }
    /deep/ .el-pagination.is-background .el-pager li:not(.disabled):hover {
        color: #2974FF;
    }
    /deep/ .el-pager li{ border-radius: 14px; background: rgba(255, 255, 255, 1); border: 1px rgba(167, 167, 167, 0.3) solid;}
    /deep/ .btn-prev{ border-radius: 14px; padding: 0 10px;}
    /deep/ .btn-next{ border-radius: 14px; padding: 0 10px;}

    /deep/ .el-table th{ background: rgb(246, 246, 246);}
    /deep/ .el-input__inner{ line-height: 36px; height: 36px; font-size: 12px; background: rgb(247, 248, 250);  border: 0;}
    /deep/ .el-date-editor .el-range-input{ background: rgb(247, 248, 250); }
    /deep/ .el-button{ padding: 11px 23px !important;}
    /deep/ .el-button--mini{ padding: 6px 15px !important;}
    /deep/ .el-button--danger {
        color: #FFF;
        background-color: #2974FF;
        border-color: #2974FF;
    }
    .team {
    	background: #F9F9F9;
    }
  }
</style>
